const test = require('ava')

const hullPoints2 = require('./hullPoints2')

test('hullPoints2 bug #114 2 circles with 18 segments', (t) => {
  const points = [
    [-2.1809221376422756, -1.0260604299770084],
    [-2, 0],
    [-2.1809221376422747, 1.0260604299770062],
    [-2.701866670643066, 1.9283628290596178],
    [-3.4999999999999996, 2.598076211353316],
    [-4.479055466999209, 2.954423259036624],
    [-5.520944533000791, 2.954423259036624],
    [-6.499999999999999, 2.598076211353316],
    [-7.298133329356934, 1.9283628290596184],
    [-7.819077862357725, 1.0260604299770066],
    [-8, 3.6739403974420594e-16],
    [-7.819077862357725, -1.026060429977006],
    [-7.298133329356935, -1.9283628290596178],
    [-6.500000000000002, -2.5980762113533156],
    [-5.520944533000791, -2.954423259036624],
    [-4.47905546699921, -2.9544232590366244],
    [-3.4999999999999996, -2.598076211353316],
    [-2.7018666706430667, -1.9283628290596186],
    [7.819077862357725, -1.0260604299770084],
    [8, 0],
    [7.819077862357725, 1.0260604299770062],
    [7.298133329356935, 1.9283628290596178],
    [6.5, 2.598076211353316],
    [5.520944533000791, 2.954423259036624],
    [4.479055466999209, 2.954423259036624],
    [3.500000000000001, 2.598076211353316],
    [2.7018666706430663, 1.9283628290596184],
    [2.180922137642275, 1.0260604299770066],
    [2, 3.6739403974420594e-16],
    [2.1809221376422747, -1.026060429977006],
    [2.7018666706430654, -1.9283628290596178],
    [3.4999999999999987, -2.5980762113533156],
    [4.479055466999209, -2.954423259036624],
    [5.52094453300079, -2.9544232590366244],
    [6.5, -2.598076211353316],
    [7.298133329356933, -1.9283628290596186]
  ]

  // we just want to be sure no err happens for this case
  const out = hullPoints2(points)
  t.is(out.length, 19)
})
